package com.cloud.template.luna.controller;

import com.cloud.template.luna.entity.User;
import com.cloud.template.luna.service.UserService;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 用户操作
 * Created by Viole on 2017/12/29.
 */
@Controller
@RequestMapping("user")
public class HelloUser {
    private static Logger logger = LogManager.getLogger(HelloUser.class);

    @Autowired
    private UserService userService;

    @RequestMapping("findUserName")
    @ResponseBody
    public String findUserName(String userName){
        User user = userService.findByUserName(userName);
        if (user == null){
            return null;
        }else {
            return user.toString();
        }
    }

}
